package com.boarsoft.boar.code.bean.service;

import com.boarsoft.boar.code.bean.biz.impl.BeanPropBizImpl;
import org.apache.logging.log4j.util.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.boarsoft.boar.code.analysis.service.BeanAnalysis;
import com.boarsoft.boar.code.analysis.service.InterfaceAnalysis;

@Service("beanService")
public class BeanServiceImpl implements BeanService {
	private static final Logger log = LoggerFactory.getLogger(BeanServiceImpl.class);
	private static final String BEAN = "bean";
	private static final String INTERFACE = "interface";
	@Autowired
	private BeanAnalysis beanAnalysis;
	@Autowired
	private InterfaceAnalysis interfaceAnalysis;
	@Autowired
	private BeanPropBizImpl beanPropBiz;

	@Override
	public String save(String type, String info) {
		if (Strings.isEmpty(type) || Strings.isEmpty(info)) {
			throw new RuntimeException("传入信息为空！！！");
		}
		if (BEAN.equals(type)) {
			beanAnalysis.execute(info);
		} else if (INTERFACE.equals(type)) {
			interfaceAnalysis.execute(info);
		} else {
			log.debug("当前未有此种情况的处理！！");
		}
		return "success";
	}

	@Override
	public String findPropType(String name, String beanClass) {
		return beanPropBiz.findPropType(name,beanClass);
	}
}